#include <bits/stdc++.h>
using namespace std;

pair<int, int> itv[100005];
int pos[100005];

int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int t;
    scanf("%d", &t);
    while (t--) {
        int n, m, L, V;
        scanf("%d %d %d %d", &n, &m, &L, &V);
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            int d, v, a;
            scanf("%d %d %d", &d, &v, &a);
            if (a == 0) {
                if (v > V) {
                    itv[cnt++] = make_pair(d, L);
                }
            } else if (a > 0) {
                if (v > V) {
                    itv[cnt++] = make_pair(d, L);
                } else {
                    int up = V * V - v * v;
                    int down = 2 * a;
                    int P = up / down + 1;
                    if (d + P <= L) {
                        itv[cnt++] = make_pair(d + P, L);
                    }
                }
            } else {
                if (v > V) {
                    int up = v * v - V * V;
                    int down = -2 * a;
                    int P = (up + down - 1) / down - 1;
                    if (d + P >= d) {
                        itv[cnt++] = make_pair(d, min(d + P, L));
                    }
                }
            }
        }
        for (int i = 0; i < m; i++) {
            scanf("%d", &pos[i]);
        }
        int oldcnt = cnt;
        cnt = 0;
        for (int i = 0; i < oldcnt; i++) {
            int x = *lower_bound(pos, pos + m, itv[i].first);
            if (itv[i].first <= x && x <= itv[i].second) {
                itv[cnt++] = itv[i];
            }
        }
        printf("%d ", cnt);
        sort(itv, itv + cnt);
        for (int i = cnt - 1; i > 0; i--) {
            itv[i - 1].second = min(itv[i - 1].second, itv[i].second);
        }
        itv[cnt].first = 0x3f3f3f3f;
        int ptr = 0, need = 0;
        while (ptr < cnt) {
            int x = *(upper_bound(pos, pos + m, itv[ptr].second) - 1);
            need++;
            ptr = upper_bound(itv, itv + cnt + 1, make_pair(x, 0x3f3f3f3f)) - itv;
            cerr << itv[ptr].first << " " << itv[ptr].second << " " << x << endl;
        }
        printf("%d\n", m - need);
    }
}
